﻿using Web.Infrastructure.Grid;

namespace Web.Infrastructure.Models
{
    /// <summary>
    /// Base model for listing with support of sorting and pagination.
    /// </summary>
    /// <typeparam name="T">Model</typeparam>
    public class BaseGridModel<T>
    {
        /// <summary>
        /// Gets or sets the items.
        /// </summary>
        /// <value>The items.</value>
        public IPagination<T> Items { get; set; }

        /// <summary>
        /// Gets or sets the sort.
        /// </summary>
        /// <value>The sort.</value>
        public GridSortOptions Sort { get; set; }

        /// <summary>
        /// Gets the page.
        /// </summary>
        public int Page
        {
            get
            {
                return Items.PageNumber;
            }
        }

        /// <summary>
        /// Gets the size.
        /// </summary>
        public int Size
        {
            get
            {
                return Items.PageSize;
            }
        }

        /// <summary>
        /// Gets the total pages.
        /// </summary>
        public int TotalPages
        {
            get
            {
                return Items.TotalPages;
            }
        }
    }
}